/**
 * @ClassNameAdminController
 * @Description TODO
 * @author 李嘉明
 * @Date 2021/1/14 19:55
 * Version 1.0
 */
package com.hdit.Admin.controller;

import com.hdit.Admin.domain.Admin;
import com.hdit.Admin.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class AdminController {
    @Autowired
    private AdminService adminService;

    @RequestMapping(value = "/adminLogin")
    public String findAdminByName(Admin admin, Model m){
        int i = adminService.findAdminByName(admin);
        if(i==1){
            return "loginSuccess";
        }
        if(i==0){
            m.addAttribute("errorMessage","用户不存在！");
        }else {
            m.addAttribute("errorMessage","密码错误！");
        }
        return  "error";
    }
}
